import sys
import string

class dna_data:
	"""Structure for holding whole data for dna sequence being reconstructed"""
	length = 0
	poly = []
	poly_lengths = 0


def read_data(f):
	"""Read input data from given file"""
	dna = dna_data();
	
	dna.length = int(f.readline())
	dna.poly_len = int(f.readline())
	
	amount = int(f.readline())
	for i in range(amount):
		dna.poly.append(f.readline()[:-1])
	
	return dna

##
used = []
out = []
def solve(d, lev=0):
	"""solve the fucking case"""

	global used, out

	if lev==0:
		used = [0 for i in range(len(d.poly))]
	
	if lev==len(d.poly):
		print "[",
		for p in out:
			print p,
		print "]"

	for i in range(len(d.poly)):
		print out[:-1][:-2]==[] or out[:-1][:-2]==d.poly[i][:2], out[-1], d.poly[i]
		if not used[i] and (out[:-1][:-2]==[] or out[:-1][:-2]==d.poly[i][:2]):
			out.append(d.poly[i])
			used[i] = True
			solve(d, lev+1)
			used[i] = False
			out.pop()
			return True
	
	return True
	
#
dna = read_data(sys.stdin)

solve(dna)

#for x in range(len(dna.poly)):
#	print dna.poly[x]